import { System } from "../lib/ecsy.module.js";
import * as Components from "./Components.js";
import {Game,MeshTool,Input} from "./game.js"

export class PlayerSystem extends System {
  execute(delta) {
    let entities = this.queries.entities.results;
    for (let i = 0; i < entities.length; i++) {
        let entity = entities[i];
        let player = entity.getComponent(Components.Object3D);

        if(Input.getKeyDown(Input.key.W)){
            player.object.position.x += delta*0.01;
        }
        if(Input.getKeyDown(Input.key.S)){
            player.object.position.x -= delta*0.01;
        }
    }
  }
}

PlayerSystem.queries = {
  entities: { components: [Components.PlayerComponent,Components.Object3D] }
};

